<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="format-detection" content="telephone=no,email=no,adress=no">
<link href="<%=request.getContextPath()%>/css/global.css" type="text/css" rel="stylesheet" />
<link href="<%=request.getContextPath() %>/js/easyui/themes/metro/easyui.css" type="text/css" rel="stylesheet"/>
<link href="<%=request.getContextPath() %>/js/date/skin/WdatePicker.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/easyui/easyui.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/date/WdatePicker.js"></script>
<script type="text/javascript">

$(function(){

	$("#dataTable").datagrid({
		toolbar: '#dataSearch',
		fitColumns:true,
		striped: true, 
		singleSelect:false,
		pagination:true,
		rownumbers:true,
		SelectOnCheck:true,
		CheckOnSelect:true,
        onSelect: function(index,row){
        	var nos="";
        	var rows = $('#dataTable').datagrid('getSelections');
        	for(var i=0; i<rows.length; i++){
        		nos=nos+rows[i].ck+",";
        	}
			$("#keys").val(nos);
    	},
    	onUnselect: function(index,row){
        	var nos="";
        	var rows = $('#dataTable').datagrid('getSelections');
        	for(var i=0; i<rows.length; i++){
        		nos=nos+rows[i].ck+",";
        	}
			$("#keys").val(nos);
    	},
    	onSelectAll: function(rows){
        	var nos="";
        	for(var i=0; i<rows.length; i++){
        		nos=nos+rows[i].ck+",";
        	}
			$("#keys").val(nos);
    	},
    	onUnselectAll: function(rows){
			$("#keys").val("");
    	}
	});
	
	$('#dataTable').datagrid('getPager').pagination({
		total:<s:property value="pageInfo.pageRecord"/>,
		pageNumber:<s:property value="pageInfo.pageIndex"/>,
		pageSize:<s:property value="pageInfo.pageSize"/>,
		pageList: [20,50,100] ,
		onSelectPage:function(pageNumber,pageSize){  
			toPage(pageNumber,pageSize);
		},
		onRefresh:function(pageNumber,pageSize){  
			location.reload();
		}
	});
	
});

function rand(){
	$.ajax
		({
	  url:"ips_random.html",
	  cache: false,
	  async: true,
	  type: "POST",
	  data:"ipsType="+$("#ipsType").val()+"&ipsCountry="+$("#ipsCountry").val(),
	  success: function(html){
		  $.MsgBox.Alert('消息',html);
	  }
	}); 
}
</script>
</head>
<body >
<div id="dataSearch" >    
<form id="sform" action="ips_list.html" method="get" enctype="multipart/form-data">
<table style="width: 100%;">
<tr>
<td height="25" >
	<b>操作说明:IP类型分IPV4和IPV6两种,选择IP类型输入国家码可以随机生成一条指定的IP地址</b> 
</td>
</tr>
<tr><td height="30" >
<s:textfield  id="ipsNumber" name="ipsNumber" placeholder="IP查询"></s:textfield>
<s:select id="ipsType" name="ipsType" list="#{'IPV4':'IPV4','IPV6':'IPV6'}" headerKey="" headerValue="IP类型"/>
<s:textfield  id="ipsCountry" name="ipsCountry" placeholder="所属国家(两位国家码)"></s:textfield>
<s:select id="ipsState" name="ipsState" list="#{'1':'有效','0':'无效'}" headerKey="" headerValue="是否有效"/>

<s:textfield  id="ipsDateTop"  name="ipsDateTop" placeholder="日期起"  onclick="WdatePicker();"  cssStyle="width:100px;" ><s:param name="value"><s:date name="ipsDateTop" format="yyyy-MM-dd"/></s:param></s:textfield>
 - 
<s:textfield  id="ipsDateEnd"  name="ipsDateEnd" placeholder="日期止"  onclick="WdatePicker();"  cssStyle="width:100px;" ><s:param name="value"><s:date name="ipsDateEnd" format="yyyy-MM-dd"/></s:param></s:textfield>

<input type="button" class="submit" value="查询搜索" onclick="sform.submit();"/>
<input type="button" class="submit" value="随机生成" onclick="rand();"/>
</td>
</tr>
<tr><td><hr/></td></tr>
<tr>
<td height="30" >
	<input type="hidden"  id="keys" name="keys"  value=""/>
		<input type="button" class="submit" value="新增记录" onclick="location.href='<%=request.getContextPath()%>/ips_edit.html'"/>
		<input type="button" class="submit" value="批量删除" onclick="location.href='<%=request.getContextPath()%>/ips_move.html?ipsNos='+$('#keys').val()"/>
		<input type="button" class="submit"   value="导出数据"  onclick="if(confirm('确认要执行导出操作吗?')){window.open(location.href.replace('list','export'));}"/>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" class="submit" value="IP排序" onclick="toSort('sortField','ipsMin')"/>
		<input type="button" class="submit" value="类型排序" onclick="toSort('sortField','ipsType')"/>
		<input type="button" class="submit" value="国家排序" onclick="toSort('sortField','ipsCountry')"/>
		<input type="button" class="submit" value="日期排序" onclick="toSort('sortField','ipsDate')"/>
		
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" class="submit" value="升序排列" onclick="toSort('sortOrder','true')"/>
		<input type="button" class="submit" value="降序排列" onclick="toSort('sortOrder','false')"/>
</td>
</tr>
</table>
</form>
</div>

<table id="dataTable" style="width: 100%;" class="easyui-datagrid" >
<thead>
<tr>
<th data-options="field:'ck'" checkbox="true"></th>
<th data-options="field:'ipsType', width:'6%',align:'left' , halign: 'left'">IP类型</th>
<th data-options="field:'ipsName', width:'10%',align:'left' , halign: 'left'">名称</th>
<th data-options="field:'ipsCountry', width:'6%',align:'left' , halign: 'left'">国家</th>
<th data-options="field:'ipsMin', width:'12%',align:'left' , halign: 'left'">起始IP</th>
<th data-options="field:'ipsMinnum', width:'15%',align:'left' , halign: 'left'">起始IP值</th>
<th data-options="field:'ipsMax', width:'12%',align:'left' , halign: 'left'">结束IP</th>
<th data-options="field:'ipsMaxnum', width:'15%',align:'left' , halign: 'left'">结束IP值</th>
<th data-options="field:'ipsState', width:'6%',align:'left' , halign: 'left'">状态</th>
<th data-options="field:'ipsDate', width:'10%',align:'left' , halign: 'left'">日期</th>
<th data-options="field:'op', width:'100',align:'left' , halign: 'left'">操作</th>

</tr>
</thead>
<tbody>
<s:iterator value="ipsList" id="show" status="seq">
<tr>
<td><s:property value="#show.ipsNo"/></td>
<td><s:property value="#show.ipsType"/></td>
<td><s:property value="#show.ipsName"/></td>
<td><s:property value="#show.ipsCountry"/></td>
<td><s:property value="#show.ipsMin"/></td>
<td><s:property value="#show.ipsMinnum"/></td>
<td><s:property value="#show.ipsMax"/></td>
<td><s:property value="#show.ipsMaxnum"/></td>
<td><s:if test="#show.ipsState==0"><img src="<%=request.getContextPath() %>/image/cancel.png"  /></s:if><s:else><img src="<%=request.getContextPath() %>/image/accept.png"  /></s:else></td>
<td><s:text name="global.format.dateminute"><s:param value="#show.ipsDate"/></s:text>
<td>
<input type="button" value="修改" style="width: 50px;"class="submit" onclick="location.href='<%=request.getContextPath()%>/ips_edit.html?ipsNo=<s:property value="#show.ipsNo"/>'"/>
</td>

</tr>
</s:iterator>
</tbody>
</table>
<br/>
<br/>
<br/>
</body>
</html>
